package com.tbb.app.base.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tbb.app.base.entity.UserNote;
import com.tbb.app.base.vo.SimpleVO;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户笔记关系表（点赞，收藏，评论） Mapper 接口
 *
 * @author Liu
 * @since 2022-01-11
 */
public interface UserNoteMapper extends BaseMapper<UserNote> {

    @Select("SELECT  " +
            "  c.`name` AS 'name',  " +
            "  count(*) AS 'value'   " +
            "FROM  " +
            "  tbb_user_note a  " +
            "  LEFT JOIN tbb_note b ON a.note_id = b.id  " +
            "  LEFT JOIN tbb_channel c ON b.channel_id = c.id   " +
            "WHERE  " +
            "  type = 2   " +
            "GROUP BY  " +
            "  b.channel_id")
    List<SimpleVO> remarkChannel();
}
